package org.example.controller;

import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.example.model.vo.R;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@Slf4j
@RestController
@RequestMapping("/api/user")
@RequiredArgsConstructor
public class UserController {

    @GetMapping("/logout")
    public R<Authentication> logout() {
        Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
        return R.ok(authentication);
    }

    @GetMapping("/test")
    public R<Authentication> testUser() {
        Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
        return R.ok(authentication);
    }
}
